<template>
	<view class="container">
		<view class="project_Img">
			<view>
				<image src="@/static/image/xiangji.png"></image>
			</view>
		</view>
		<view class="login">
			<view class="item">
				<view>用户名：</view>
				<input type="text" v-model="username" />
			</view>
			<view class="item">
				<view>密码：</view>
				<input type="password" v-model="password" />
			</view>
			<view class="btn" @click="headleLogin">登录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				username: 'admin',
				password: '123456'
			}
		},
		onLoad() {},

		methods: {

			headleLogin() {
				this.myRequesy({
					url: 'admin/login',
					method: 'POST',
					data: {
						username: this.username,
						password: this.password
					}
				}).then(res => {
					if (res.data.code === 0) {
						uni.setStorage({
							key: 'token',
							data: res.data.data.token,
							success() {
								uni.navigateTo({
									url: '../index/index'
								})
							}
						})
					} else {
						uni.showToast({
							title: res.data.msg
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		.project_Img {
			margin-top: 300upx;
			display: flex;
			justify-content: center;
			align-items: center;

			view {
				width: 200upx;
				height: 200upx;
				background-color: #eee;
				display: flex;
				justify-content: center;
				align-items: center;
				border-radius: 20upx;
			}

			image {
				width: 120upx;
				height: 120upx;
			}
		}

		.login {
			// background-color: #fff;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			margin-top: 80upx;
			margin-left: -30upx;

			.item {
				display: flex;
				margin-bottom: 30upx;

				view {
					width: 150upx;
					font-weight: 600;
				}

				input {
					padding-left: 10upx;
					width: 400upx;
					height: 80upx;
					background-color: #eee;

				}
			}

			.btn {
				width: 600upx;
				height: 80upx;
				background-color: #007AFF;
				border-radius: 40upx;
				text-align: center;
				color: #fff;
				font-weight: 600;
				line-height: 80upx;
				margin-top: 20upx;
			}
		}
	}
</style>
